package ee.logsimulator.data;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * @author Romet Piho
 */
public class Event implements Comparable<Event> {

  private Date timestamp;
  private Actor source;
  private Spell spell;
  private Actor target;
  private Amount amount;
  private int pixelTime;
  private Type type;
  private int subType;

  public Date getTimestamp() {
    return timestamp;
  }

  public void setTimestamp(Date timestamp) {
    this.timestamp = timestamp;
  }

  public Actor getSource() {
    return source;
  }

  public void setSource(Actor source) {
    this.source = source;
  }

  public Actor getTarget() {
    return target;
  }

  public void setTarget(Actor target) {
    this.target = target;
  }

  public Spell getSpell() {
    return spell;
  }

  public void setSpell(Spell spell) {
    this.spell = spell;
  }

  public Amount getAmount() {
    return amount;
  }

  public void setAmount(Amount amount) {
    this.amount = amount;
  }

  public int getPixelTime() {
    return pixelTime;
  }

  public void setPixelTime(int pixelTime) {
    this.pixelTime = pixelTime;
  }

  @Override
  public boolean equals(Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj);
  }

  @Override
  public int hashCode() {
    return HashCodeBuilder.reflectionHashCode(this);
  }

  @Override
  public String toString() {
    SimpleDateFormat f = new SimpleDateFormat("HH:mm:ss.SSS ");
    return f.format(timestamp) + source + " " + spell + " " + target + " " + amount;
  }

  @Override
  public int compareTo(Event o) {
    return getTimestamp().compareTo(o.getTimestamp());
  }

  public Type getType() {
    return type;
  }

  public void setType(Type type) {
    this.type = type;
  }

  public int getSubType() {
    return subType;
  }

  public void setSubType(int subType) {
    this.subType = subType;
  }
}
